﻿using QD.PushManager.DB;
using QD.PushManager.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QD.PushManager.Manager
{
    /// <summary>
    /// 订阅宝产品推送日志
    /// </summary>
    public static class ProductLogManager
    {
        /// <summary>
        /// 是否推送
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public static bool IsPush(int userId, DateTime date)
        {
            int id = 0;
            var sql = string.Format("select top 1 itemid from sql_s003.dbo.vifo_product_log_wx  where userid={0} and DATEDIFF(dd,AddTime,{1})=0", userId, date.ToString("yyyy-MM-dd"));
            using (var db = new ShtDatabase())
            {
                id = db.ExecuteScalar<int>(sql);
            }
            return id > 0;
        }
    }
}
